package com.cg.resolvers;

import com.cg.entities.User;
import com.cg.input.LoginInput;
import com.cg.input.UserId;
import com.cg.input.UserInput;
import com.cg.service.UserService;
import com.netflix.graphql.dgs.DgsComponent;
import com.netflix.graphql.dgs.DgsMutation;
import com.netflix.graphql.dgs.DgsQuery;
import lombok.RequiredArgsConstructor;

/**
 * @author cheyinbo
 * @description TODO
 * @date 2021/6/24 15:27
 */
@DgsComponent
@RequiredArgsConstructor
public class UserResolver {

    private final UserService userService;

    @DgsQuery
    public User login(LoginInput loginInput){
        return userService.login(loginInput);
    }
    @DgsQuery
    public User queryUser(UserId userId){
        return userService.queryUser(userId);
    }
    @DgsMutation
    public User insertUser(UserInput userInput){
        return userService.insertUser(userInput);
    }
    @DgsMutation
    public Boolean deleteUser(UserId userId){
        return userService.deleteUser(userId);
    }
    @DgsMutation
    public Boolean updateUser(UserInput userInput){
        return userService.updateUser(userInput);
    }

}
